package oocl.ita.eordering.listener;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;


/**
 * Application Lifecycle Listener implementation class sdf
 *
 */
public class ConfigListener implements ServletContextListener {
	private static Properties prop = new Properties();

    /**
     * Default constructor. 
     */
    public ConfigListener() {
        // TODO Auto-generated constructor stub
    }

	/**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent sce)  { 
         // TODO Auto-generated method stub
    }

	/**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent sce)  { 
    	
    	try {
			prop.load(new FileInputStream(ConfigListener.class.getClassLoader().getResource("PicServerConfig.properties").getPath()));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		String myPicServer = prop.getProperty("myPicServer");
		ServletContext app=sce.getServletContext();
		app.setAttribute("myPicServer", myPicServer);
		
    }
	
}
